package com.lovo.controller;

import com.lovo.model.ClassDO;
import com.lovo.model.CourseDO;
import com.lovo.service.IClassService;
import com.lovo.service.ICourseService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description:
 *
 * @author LiuChengQi
 * @date Created on 2020/11/23
 */
@Controller
@RequestMapping("/course")
public class CourseController {
    @Resource
    private ICourseService service;
    @GetMapping
    public List findAll(String name){
        System.out.println(name);
        return service.findAll();
    }
    @PostMapping
    public String save(CourseDO courseDO){
        service.save(courseDO);
        return "增加";
    }
    @PutMapping("/{id}")
    public String update(@PathVariable("id") String id, @RequestBody CourseDO courseDO){
        System.out.println("id:"+courseDO);
        courseDO.setId(id);
        service.update(courseDO);
        return "update : "+courseDO;
    }
    @DeleteMapping("/{id}")
    public String delete(@PathVariable("id") String id){
        service.remove(id);
        return "delete "+id;
    }
}
